package com.hmall.user.web;

import com.hmall.user.pojo.Address;
import com.hmall.user.service.AddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/address")
public class AddressController {

    @Autowired
    private AddressService addressService;

    // 根据用户id查询地址列表
    @GetMapping("/uid")
    public List<Address> findAddressByUid() {
        return addressService.findAddressByUid();
    }

    @GetMapping("{addressId}")
    public Address getAddress(@PathVariable("addressId")Long addrId){
        return addressService.getAddress(addrId);
    }
}
